﻿<local:PageBase x:Class="MicroBlogClient.MetionedMe"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      mc:Ignorable="d"     xmlns:local="clr-namespace:MicroBlogClient"
        xmlns:controls="clr-namespace:Rabbit.Controls;assembly=Rabbit.Controls"
      d:DesignHeight="300" d:DesignWidth="300"
	Title="MetionedMe">
    <local:PageBase.Resources>
        <DataTemplate x:Key="StatusItemTemplate">
            <DataTemplate.Resources>
                <Storyboard x:Key="YellowFade">
                    <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="grid" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" FillBehavior="Stop">
                        <SplineColorKeyFrame KeyTime="00:00:00" Value="#FFFEFF76" />
                        <SplineColorKeyFrame KeyTime="00:00:20" Value="#19FEFF76" />
                    </ColorAnimationUsingKeyFrames>
                </Storyboard>
            </DataTemplate.Resources>
            <DockPanel Margin="0,10,0,10" x:Name="grid" Background="Transparent">
                <!--User Picture-->
                <Border VerticalAlignment="Top" Width="40">
                    <Border BorderBrush="White" DockPanel.Dock="Left" CornerRadius="5" Height="40" Width="40" BorderThickness="1">
                        <Image Stretch="UniformToFill" MouseEnter="UserHeadPicture_MouseEnter"  MouseLeave="UserHeadPicture_MouseLeave" 
                               Source="{Binding User.ProfileImageUrl, Converter={StaticResource ImageConverter}, IsAsync=True}" />
                    </Border>
                </Border>
                <!--Status Text-->
                <StackPanel Margin="10,0,0,0">
                    <!--User/Status Information-->
                    <StackPanel Orientation="Horizontal">
                        <TextBlock TextWrapping="Wrap" Canvas.Top="0" Width="Auto"><Hyperlink CommandParameter="{Binding User.Id}"  Click="OpenUserPage_Click"><Run Text="{Binding User.ScreenName}"/></Hyperlink></TextBlock>
                        <ContentControl Visibility="{Binding User.Verified, Converter={StaticResource BooleanToVisibilityConverter}}" Content="{DynamicResource CertificateUser}"/>
                        <!--<TextBlock Foreground="Gray" 
                                   Margin="5,0,0,0"
                                   Visibility="{Binding IsMouseOver,Converter={StaticResource ContrastBooleanToVisibilityConverter},RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}, Mode=FindAncestor}}"
                                   Text="{Binding CreatedAt, Converter={StaticResource ResourceKey=DateTimeFormatConverter}}"/>-->
                        <TextBlock Foreground="Gray" Margin="5,0,0,0" 
                                   ToolTip="{Binding CreatedAt, Converter={StaticResource ResourceKey=DateTimeFormatConverter},ConverterParameter={}yyy-MM-dd HH:mm:ss,StringFormat={}发表于{0}}"
                                   Text="{Binding CreatedAt, Converter={StaticResource ResourceKey=DateTimeFormatConverter}}"/>
                    </StackPanel>
                    <!--Status Inforamtion:Text and Picture(if exist)-->
                    <DockPanel Margin="10,10,0,0">
                        <!--Status text-->
                        <controls:TextBlockEx Foreground="{DynamicResource StatusForegroundBrush}" LineHeight="20" Text="{Binding Text}" DockPanel.Dock="Top" TextWrapping="Wrap">
                            <controls:TextBlockEx.ContextMenu>
                                <ContextMenu>
                                    <MenuItem Header="复制" x:Name="menuCopyStatus" CommandParameter="{Binding Text}" Click="menuCopyStatus_Click"/>
                                </ContextMenu>
                            </controls:TextBlockEx.ContextMenu>
                        </controls:TextBlockEx>
                        <controls:ImageEx  Stretch="None" MaxHeight="200" MaxWidth="400"
                            Source="{Binding SmallPic, Converter={StaticResource ImageConverter}, IsAsync=True}"  
                            LargerPictureSource="{Binding MiddlePic}" Cursor="Hand" x:Name="statusImage" PreviewMouseLeftButtonUp="statusImage_PreviewMouseLeftButtonUp" HorizontalAlignment="Left" >
                            <controls:ImageEx.ToolTip>点击看大图</controls:ImageEx.ToolTip>
                        </controls:ImageEx>
                    </DockPanel>
                    <!--forwared status(if is forwarded status) Inforamtion:Text and Picture(if exist)-->
                    <TextBlock Margin="10,5,0,0" Visibility="{Binding InReplyToStatusText, Converter={StaticResource StringToVisibilityConverter}}"><InlineUIContainer>
                    		<Border BorderBrush="{DynamicResource FowardedStatusLeftLineBrush}" BorderThickness="1,0,0,0">
                    			<TextBlock Margin="5,0,0,0"><InlineUIContainer>
                    					<TextBlock  VerticalAlignment="Top"><Hyperlink Click="OpenUserPage_Click" CommandParameter="{Binding InReplyToUserId}"><InlineUIContainer>
                    								<TextBlock><Run Text="@"/></TextBlock>
                    							</InlineUIContainer><InlineUIContainer>
                    								<TextBlock Text="{Binding InReplyToScreenName}"/>
                    							</InlineUIContainer><InlineUIContainer>
                    								<TextBlock><Run Text=":"/></TextBlock>
                    							</InlineUIContainer></Hyperlink></TextBlock>
                    				</InlineUIContainer><Run Text=" "/><InlineUIContainer>
                    					<TextBlock Visibility="{Binding IsMouseOver, Converter={StaticResource BooleanToVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}, Mode=FindAncestor}}" >
                                            <Hyperlink CommandParameter="1" 
                                                       x:Name="linkForward" Click="ForwardStatusHandler">
                                                <Run Text="{Binding InReplyToTransmitCount,StringFormat={}转原文({0})}"/></Hyperlink>
                    							<TextBlock Margin="3,0,4,0"/>
                                            <Hyperlink CommandParameter="1" 
                                                       x:Name="linkReplyComment"
                                                       Click="ReplyStatusHandler">
                                                <Run Text="{Binding InReplyToCommentsCount,StringFormat={}评原文({0})}"/>
                                            </Hyperlink></TextBlock>
                    				</InlineUIContainer><LineBreak/><InlineUIContainer>
                    					<StackPanel>
                    						<controls:TextBlockEx Padding="5,0,0,0" LineHeight="20" Foreground="{DynamicResource FowardedStatusForegroundBrush}" Text="{Binding InReplyToStatusText, IsAsync=True}"  TextWrapping="Wrap">
                    							<controls:TextBlockEx.ContextMenu>
                    								<ContextMenu>
                    									<MenuItem Header="复制" CommandParameter="{Binding InReplyToStatusText}" Click="menuCopyStatus_Click"/>
                    								</ContextMenu>
                    							</controls:TextBlockEx.ContextMenu>
                    						</controls:TextBlockEx>
                    						<controls:ImageEx  Visibility="{Binding InReplyToHasImage, Converter={StaticResource BooleanToVisibilityConverter}}"
                    							Source="{Binding InReplyToSmallImageUrl, Converter={StaticResource ImageConverter}, IsAsync=True}" 
                    							LargerPictureSource="{Binding InReplyToMiddleImageUrl}" Cursor="Hand" x:Name="statusReplyToImage" PreviewMouseLeftButtonDown="statusImage_PreviewMouseLeftButtonUp" HorizontalAlignment="Left" Stretch="None">
                    							<controls:ImageEx.ToolTip>点击看大图</controls:ImageEx.ToolTip>
                    						</controls:ImageEx>
                    					</StackPanel>
                    				</InlineUIContainer></TextBlock>
                    		</Border>
                    	</InlineUIContainer></TextBlock>
                    <TextBlock Margin="0,10,0,0">
                       <TextBlock Text="{Binding Source}" Foreground="Gray" />
                        <TextBlock  Margin="5,0,0,0">
                            <!--Visibility="{Binding IsMouseOver, Converter={StaticResource BooleanToVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}, Mode=FindAncestor}}"-->
                            <Hyperlink CommandParameter="0" Click="ForwardStatusHandler" >
                                <Run Text="{Binding TransmitCount,StringFormat={}转发({0})}"/></Hyperlink>
                        	<TextBlock Margin="2,0,0,0"/>
                        	<Hyperlink CommandParameter="0" Click="ReplyStatusHandler">
                               <Run Text="{Binding CommentsCount,StringFormat={}评论(0)}"/></Hyperlink>
                        		<TextBlock Margin="2,0,0,0"/>
                        	<Hyperlink CommandParameter="{Binding Id}" Click="AddStatusToFavoritesHandler"><Run Text="收藏"/></Hyperlink></TextBlock>
                    </TextBlock>
                </StackPanel>
            </DockPanel>
            <DataTemplate.Triggers>
                <DataTrigger Binding="{Binding IsNew}" Value="true">
                    <DataTrigger.EnterActions>
                        <BeginStoryboard Storyboard="{StaticResource YellowFade}" x:Name="YellowFade_BeginStoryboard" />
                    </DataTrigger.EnterActions>
                </DataTrigger>
            </DataTemplate.Triggers>
        </DataTemplate>
    </local:PageBase.Resources>
    <Grid>
        
    <ListBox Canvas.Left="0" Grid.Row="0" x:Name="lstMetionedMeStatusList" BorderThickness="0"
                                                                 ItemContainerStyle="{DynamicResource ListBoxItemStyle}"  Margin="0"
                                                                 ScrollViewer.HorizontalScrollBarVisibility="Disabled"  
                                                                 ScrollViewer.CanContentScroll="False"
                                                                 ItemTemplate="{StaticResource ResourceKey=StatusItemTemplate}"
                                                                 Foreground="Black"/>
     <StackPanel VerticalAlignment="Bottom" Grid.Row="1" HorizontalAlignment="Center"  Orientation="Horizontal">
            <local:UCPager x:Name="pager" OnFirstPageClick="pager_OnFirstPageClick"
                           OnPreviousePage="pager_OnPreviousePage"
                           OnNextPageClick="pager_OnNextPageClick"/>
        </StackPanel>
    </Grid>
</local:PageBase>
